<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<title>客供料执行</title>

	<!-- bootstrap -->
	<link href="__CSS__/bootstrap/bootstrap.css" rel="stylesheet" />

	<!-- libraries -->
	<!-- <link href="css/libs/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" /> -->
	<link href="__CSS__/libs/font-awesome.css" type="text/css" rel="stylesheet" />

	<!-- global styles -->
	<link rel="stylesheet" type="text/css" href="__CSS__/compiled/layout.css">
	<link rel="stylesheet" type="text/css" href="__CSS__/compiled/elements.css">

	<!-- this page specific styles -->
	<link rel="stylesheet" type="text/css" href="__CSS__/libs/bootstrap-wizard.css">
	<link rel="stylesheet" href="__CSS__/libs/select2.css" type="text/css" />

	<link rel="stylesheet" href="__CSS__/new.css"/>
	<link rel="stylesheet" href="__CSS__/table.css"/>
	<link rel="stylesheet" href="__CSS__/bootstrap-table.css"/>
	<link rel="stylesheet" href="__CSS__/bootstrap-table-fixed-columns.css"/>

	<!-- Favicon -->
	<!--<link type="image/x-icon" href="favicon.png" rel="shortcut icon"/>-->

	<!-- google font libraries -->
	<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'>

	<!--[if lt IE 9]>
	<!--<script src="__JS__/html5shiv.js"></script>
	<script src="__JS__/respond.min.js"></script>-->
	<![endif]-->
	<!--[if lt IE 8]>-->
		<!--<link href="__CSS__/libs/font-awesome-ie7.css" type="text/css" rel="stylesheet" />-->
	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	  ga('create', 'UA-49262924-1', 'phoonio.com');
	  ga('send', 'pageview');

	</script>
	<style>
		.main-box{
			min-height: 820px;
		}
		@media (max-width:1320px){
			.main-box{
				min-height: 600px;
			}
		}

		.fixed-table-body-columns{
			height: 486px!important;
			top: 47px!important;
		}

		.wizard-steps{
			display: none;
		}
		.wizard-card{
			width:400px!important;
			height: 320px!important;
		}
		.wizard-modal.modal{
			width:400px!important;
			height: 430px!important;
			margin-left: -200px!important;
		}
		.wizard-back{
			display: none!important;
		}
		.calCancel{
			float: right;
		}

	</style>
</head>
<body>
	<!--head-->
	{include file="pub/head"/}

	<div class="container" role="main">
		<div class="row">

				<!--left-->
				{include file="pub/left"/}

			<div class="col-md-10" id="content-wrapper">
				<!--<h2 class="pull-left">Last orders</h2>-->
				<div class="row">
					<div class="col-lg-12">

							<div class="col-lg-12">
								<div class="main-box">

									<!--提示框-->
									{include file="pub/tips"/}

									<div class="clear-fix">
										<div class="clear-fix">
											{if condition="in_array('ModelSupply/exportSupply',$ownways)"}
											<a href="{:url('ModelSupply/exportSupply')}" class="btn btn-primary">
												<i class="fa fa-download fa-lg"></i> 导出客供料执行列表
											</a>
											{/if}
										</div>
										<div class="filter-block pull-right">
											<form action="{:url('ModelSupply/search')}" method="post">
												<div class="form-group pull-left" style="margin-top: 7px;font-size: 16px;">
													<label>采购状态</label>
												</div>
												<div class="form-group pull-left">
													<select name="product_status" id="product_status" class="form-control">
														<option value=""></option>
														<option value="0">未采购</option>
														<option value="1">采购中</option>
														<option value="2">已交付</option>
													</select>
												</div>
												<button class="btn btn-primary pull-right">
													<i class="fa fa-search search-icon"></i> 搜索
												</button>

											</form>
										</div>

									</div>
									<br>
									<div class="table-responsive clearfix">
										<table id="fixedTable" class="table table-striped jambo_table table-hover" data-toggle="table">
											<thead>
												<tr>
													<th><span>国家 客户</span></th>
													<th><span>模块型号</span></th>
													<th><span>订单数量</span></th>
													<th><span>配件</span></th>
													<th><span>客供料型号</span></th>
													<th><span>供应商</span></th>
													<th><span>采购状态</span></th>
													<th><span>操作</span></th>
												</tr>
											</thead>
											<tbody>
												{volist name="modelSupplies" id="v"}
												<tr>
													<td>{$v.state} {$v.client}</td>
													<td>{$v.model_type}</td>
													<td>{$v.order_qty}</td>
													{if condition="($v['fitid'] eq '') || ($v['fitid'] eq '0')"}
													<td>/</td>
													{else/}
													<td>{$v.fitting}</td>
													{/if}
													<td>{$v.sup_type}</td>
													<td>{$v.provider}</td>
                                                    {if condition="$v['product_status'] eq '0'"}
													<td>未采购</td>
                                                    {elseif condition="$v['product_status'] eq '1'"}
                                                    <td>采购中</td>
                                                    {else/}
                                                    <td>已采购</td>
                                                    {/if}
													<td>
														{if condition="in_array('ModelSupply/esave',$ownways)"}
														<a href="#" class="table-link" onclick=edit("{$v['mod_sup_id']}") title="修改">
															<span class="fa-stack">
																<i class="fa fa-square fa-stack-2x"></i>
																<i class="fa fa-pencil fa-stack-1x fa-inverse"></i>
															</span>
														</a>
														{/if}
													</td>
												</tr>
												{/volist}

											</tbody>
										</table>
										<!--分页-->
										<div style="text-align: center;">
											{$page}
										</div>
									</div>
									<!--修改弹出框-->
									{include file="modsup/edit"/}
								</div>
							</div>
						</div>
						
					<!--</div>
				</div>-->
			</div>
		</div>
	</div>
	<!--foot-->
	{include file="pub/foot"/}
	</div>
	<!-- global scripts -->
	<script src="__JS__/jquery.js"></script>

	<script src="__JS__/bootstrap.min.js"></script>

	<!-- this page specific scripts -->
	<script src="__JS__/bootstrap-wizard.js"></script>
	<script src="__JS__/select2.min.js"></script>

	<!-- theme scripts -->
	<script src="__JS__/scripts.js"></script>
	<script src="__JS__/bootstrap-table.js"></script>
	<script src="__JS__/bootstrap-table-fixed-columns.js"></script>
	<script>

		$('#sel2').select2();
        $("#msg").addClass('forhid')

		$.fn.wizard.logging = false;

		var foredit = $("#wizard-edit").wizard({
			showCancel: true
		});

		$(".wizard-group-list").click(function() {
			alert("Disabled for demo.");
		});

		$("#open-wizard").click(function() {
			wizard.show();
			$('.wizard-cancel').text('取消');
			$('.wizard-cancel').addClass('calCancel')
			// $('.wizard-next').addClass('calCancel')
			$('.wizard-next').text('确定');
		});

		//wizard.show();

        function changeText(msg, code) {
            $('#sp').text(msg)
            if(code != 1){
                $('#img').attr('src', '__IMG__/fail.png')
            }
            $("#msg").removeClass('forhid')
            setTimeout("showOrHid()", 3000)
        }
        function showOrHid() {
            //console.log('123')
            /*淡出效果*/
            $("#msg").fadeOut(2000)
            // $("#msg").addClass('forhid')
        }

        function edit(mod_sup_id) {
            $.post("{:url('ModelSupply/one')}",{mod_sup_id:mod_sup_id},function(data){
                // console.log(data);
                if(data) {
                    $("input[name='mod_sup_id_edit']").val(data.mod_sup_id)
                    $("input[name='sup_type_edit']").val(data.sup_type);
                    $("input[name='model_type_edit']").val(data.model_type);
                    $("input[name='provider_edit']").val(data.provider);
                    $("select[name='status_edit']").val(data.product_status);
                    $("input[name='state_edit']").val(data.state+data.client);
                    $("input[name='fitting_edit']").val(data.fitting);
                }
            },'json');

            foredit.show()
            $('.wizard-cancel').text('取消');
            $('.wizard-cancel').addClass('calCancel')
            // $('.wizard-next').addClass('calCancel')
            $('.wizard-next').text('确定');

            foredit.on("submit", function(wizard) {
                setTimeout(function() {
                    wizard.trigger("success");
                    wizard.hideButtons();
                    wizard._submitting = false;
                    wizard.showSubmitCard("success");
                    wizard.updateProgressBar(0);
                }, 1000);
                esave();
                foredit.reset().close();
                setTimeout(function () {
                    //刷新页面
                    window.location.reload();
                },1000)
            });

        }

        function esave() {
            var mod_sup_id = $("input[name='mod_sup_id_edit']").val();
            var status = $("select[name='status_edit']").val();
            var data = {'mod_sup_id':mod_sup_id,'product_status':status};
            //console.log(data)
            $.ajax({
                //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "{:url('ModelSupply/esave')}",//url
                data: data,
                success: function (result) {
                    //console.log(result)
                    var code = result.code
                    var msg = result.msg
                    changeText(msg, code)
                    //console.log('123'+code)
                },
                error:function (result) {
                    var code = 0
                    var msg = '服务器错误';
                    changeText(msg, code)

                }
            });
        }

	</script>
</body>
</html>